<template>
  <div class="categoryright">
    <scroll class="content" :probeType="2" :pull-up-load="true" ref="scroll">
      <div class="rightInfo" v-for="(item, index) in rightInfo">
        <a :href="item.link">
          <img :src="item.image" alt="" @load="imgLoad" />
          <div>{{ item.title }}</div>
        </a>
      </div>
      <cate-title @titleClick="titleClick"></cate-title>
      <goods-list :goods="titleInfo"></goods-list>
    </scroll>
  </div>
</template>

<script>
import GoodsList from "components/content/goods/GoodsList";
import Scroll from "components/common/scroll/scroll.vue";
import CateTitle from "views/category/childComps/CateTitle";
import { itemListenerMixin, backTopMixin } from "common/mixin"; //防抖函数和mixin使用的封装
export default {
  name: "CategoryRight",
  props: {
    rightInfo: {
      type: Array,
      default: [],
    },
    titleInfo: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {
      saveY: 0,
    };
  },
  deactivated() {
    this.saveY = this.$refs.scroll.scroll.y;
  },
  activated() {
    this.$refs.scroll.refresh();
    this.$refs.scroll.scrollTo(0, this.saveY);
  },
  mixins: [itemListenerMixin, backTopMixin],
  methods: {
    imgLoad() {
      this.newRefresh();
    },
    titleClick(index){
      this.$emit('titleClick',index)
    }
  },
  components: {
    GoodsList,
    CateTitle,
    Scroll,
  },
};
Scroll;
</script>

<style  scoped>
.categoryright {
  width: 70%;
  float: left;
  padding: 5px 10px;
}
.content {
  overflow: hidden;
  position: absolute;
  top: 44px;
  bottom: 49px;
}
.rightInfo {
  display: inline-block;
  font-size: 14px;
  text-align: center;
  width: 25%;
  margin:10px;
}
.rightInfo img {
  width: 100%;
  height: 100%;
  margin-bottom: 3px;
}
</style>
